<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Platform Security Architecture — cryptography and keystore interface: Message authentication codes</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Platform Security Architecture — cryptography and keystore interface
   &#160;<span id="projectnumber">Working draft</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Message authentication codes</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ga78f0838b0c4e3db28b26355624d4bd37"><td class="memItemLeft" align="right" valign="top">typedef struct psa_mac_operation_s&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a></td></tr>
<tr class="separator:ga78f0838b0c4e3db28b26355624d4bd37"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga68ac2ad3253e9e27fcfbc788a4df8177"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__MAC.html#ga68ac2ad3253e9e27fcfbc788a4df8177">psa_mac_sign_setup</a> (<a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *operation, <a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> key, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg)</td></tr>
<tr class="separator:ga68ac2ad3253e9e27fcfbc788a4df8177"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac7d1c3d075ce1604a54cbbc9933fa39d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__MAC.html#gac7d1c3d075ce1604a54cbbc9933fa39d">psa_mac_verify_setup</a> (<a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *operation, <a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a> key, <a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a> alg)</td></tr>
<tr class="separator:gac7d1c3d075ce1604a54cbbc9933fa39d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5560af371497babefe03c9da4e8a1c05"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__MAC.html#ga5560af371497babefe03c9da4e8a1c05">psa_mac_update</a> (<a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *operation, const uint8_t *input, size_t input_length)</td></tr>
<tr class="separator:ga5560af371497babefe03c9da4e8a1c05"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac22bc0125580c96724a09226cfbc97f2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__MAC.html#gac22bc0125580c96724a09226cfbc97f2">psa_mac_sign_finish</a> (<a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *operation, uint8_t *mac, size_t mac_size, size_t *mac_length)</td></tr>
<tr class="separator:gac22bc0125580c96724a09226cfbc97f2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac92b2930d6728e1be4d011c05d485822"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__MAC.html#gac92b2930d6728e1be4d011c05d485822">psa_mac_verify_finish</a> (<a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *operation, const uint8_t *mac, size_t mac_length)</td></tr>
<tr class="separator:gac92b2930d6728e1be4d011c05d485822"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacd8dd54855ba1bc0a03f104f252884fd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__MAC.html#gacd8dd54855ba1bc0a03f104f252884fd">psa_mac_abort</a> (<a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *operation)</td></tr>
<tr class="separator:gacd8dd54855ba1bc0a03f104f252884fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="ga78f0838b0c4e3db28b26355624d4bd37"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga78f0838b0c4e3db28b26355624d4bd37">&#9670;&nbsp;</a></span>psa_mac_operation_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct psa_mac_operation_s <a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>The type of the state data structure for multipart MAC operations.</p>
<p>This is an implementation-defined <code>struct</code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation. </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="gacd8dd54855ba1bc0a03f104f252884fd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacd8dd54855ba1bc0a03f104f252884fd">&#9670;&nbsp;</a></span>psa_mac_abort()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_mac_abort </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *&#160;</td>
          <td class="paramname"><em>operation</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Abort a MAC operation.</p>
<p>Aborting an operation frees all associated resources except for the <code>operation</code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="el" href="group__MAC.html#ga68ac2ad3253e9e27fcfbc788a4df8177">psa_mac_sign_setup()</a> or <a class="el" href="group__MAC.html#gac7d1c3d075ce1604a54cbbc9933fa39d">psa_mac_verify_setup()</a> again.</p>
<p>You may call this function any time after the operation object has been initialized by any of the following methods:</p><ul>
<li>A call to <a class="el" href="group__MAC.html#ga68ac2ad3253e9e27fcfbc788a4df8177">psa_mac_sign_setup()</a> or <a class="el" href="group__MAC.html#gac7d1c3d075ce1604a54cbbc9933fa39d">psa_mac_verify_setup()</a>, whether it succeeds or not.</li>
<li>Initializing the <code>struct</code> to all-bits-zero.</li>
<li>Initializing the <code>struct</code> to logical zeros, e.g. <code>psa_mac_operation_t operation = {0}</code>.</li>
</ul>
<p>In particular, calling <a class="el" href="group__MAC.html#gacd8dd54855ba1bc0a03f104f252884fd">psa_mac_abort()</a> after the operation has been terminated by a call to <a class="el" href="group__MAC.html#gacd8dd54855ba1bc0a03f104f252884fd">psa_mac_abort()</a>, <a class="el" href="group__MAC.html#gac22bc0125580c96724a09226cfbc97f2">psa_mac_sign_finish()</a> or <a class="el" href="group__MAC.html#gac92b2930d6728e1be4d011c05d485822">psa_mac_verify_finish()</a> is safe and has no effect.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Initialized MAC operation.</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td><code>operation</code> is not an active MAC operation. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gac22bc0125580c96724a09226cfbc97f2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac22bc0125580c96724a09226cfbc97f2">&#9670;&nbsp;</a></span>psa_mac_sign_finish()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_mac_sign_finish </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *&#160;</td>
          <td class="paramname"><em>operation</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>mac</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>mac_size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>mac_length</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Finish the calculation of the MAC of a message.</p>
<p>The application must call <a class="el" href="group__MAC.html#ga68ac2ad3253e9e27fcfbc788a4df8177">psa_mac_sign_setup()</a> before calling this function. This function calculates the MAC of the message formed by concatenating the inputs passed to preceding calls to <a class="el" href="group__MAC.html#ga5560af371497babefe03c9da4e8a1c05">psa_mac_update()</a>.</p>
<p>When this function returns, the operation becomes inactive.</p>
<dl class="section warning"><dt>Warning</dt><dd>Applications should not call this function if they expect a specific value for the MAC. Call <a class="el" href="group__MAC.html#gac92b2930d6728e1be4d011c05d485822">psa_mac_verify_finish()</a> instead. Beware that comparing integrity or authenticity data such as MAC values with a function such as <code>memcmp</code> is risky because the time taken by the comparison may leak information about the MAC value which could allow an attacker to guess a valid MAC and thereby bypass security controls.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active MAC operation. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">mac</td><td>Buffer where the MAC value is to be written. </td></tr>
    <tr><td class="paramdir"></td><td class="paramname">mac_size</td><td>Size of the <code>mac</code> buffer in bytes. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">mac_length</td><td>On success, the number of bytes that make up the MAC value. This is always <a class="el" href="crypto__sizes_8h.html#aa84c5fb384ac7cb1bfc52adde96588ee">PSA_MAC_FINAL_SIZE</a>(<code>key_type</code>, <code>key_bits</code>, <code>alg</code>) where <code>key_type</code> and <code>key_bits</code> are the type and bit-size respectively of the key and <code>alg</code> is the MAC algorithm that is calculated.</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not started, or already completed). </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga695025f4ec11249aee7ea3d0f65e01c8">PSA_ERROR_BUFFER_TOO_SMALL</a></td><td>The size of the <code>mac</code> buffer is too small. You can determine a sufficient buffer size by calling <a class="el" href="crypto__sizes_8h.html#aa84c5fb384ac7cb1bfc52adde96588ee">PSA_MAC_FINAL_SIZE()</a>. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga68ac2ad3253e9e27fcfbc788a4df8177"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga68ac2ad3253e9e27fcfbc788a4df8177">&#9670;&nbsp;</a></span>psa_mac_sign_setup()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_mac_sign_setup </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *&#160;</td>
          <td class="paramname"><em>operation</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a>&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a>&#160;</td>
          <td class="paramname"><em>alg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Start a multipart MAC calculation operation.</p>
<p>This function sets up the calculation of the MAC (message authentication code) of a byte string. To verify the MAC of a message against an expected value, use <a class="el" href="group__MAC.html#gac7d1c3d075ce1604a54cbbc9933fa39d">psa_mac_verify_setup()</a> instead.</p>
<p>The sequence of operations to calculate a MAC is as follows:</p><ol type="1">
<li>Allocate an operation object which will be passed to all the functions listed here.</li>
<li>Call <a class="el" href="group__MAC.html#ga68ac2ad3253e9e27fcfbc788a4df8177">psa_mac_sign_setup()</a> to specify the algorithm and key. The key remains associated with the operation even if the content of the key slot changes.</li>
<li>Call <a class="el" href="group__MAC.html#ga5560af371497babefe03c9da4e8a1c05">psa_mac_update()</a> zero, one or more times, passing a fragment of the message each time. The MAC that is calculated is the MAC of the concatenation of these messages in order.</li>
<li>At the end of the message, call <a class="el" href="group__MAC.html#gac22bc0125580c96724a09226cfbc97f2">psa_mac_sign_finish()</a> to finish calculating the MAC value and retrieve it.</li>
</ol>
<p>The application may call <a class="el" href="group__MAC.html#gacd8dd54855ba1bc0a03f104f252884fd">psa_mac_abort()</a> at any time after the operation has been initialized with <a class="el" href="group__MAC.html#ga68ac2ad3253e9e27fcfbc788a4df8177">psa_mac_sign_setup()</a>.</p>
<p>After a successful call to <a class="el" href="group__MAC.html#ga68ac2ad3253e9e27fcfbc788a4df8177">psa_mac_sign_setup()</a>, the application must eventually terminate the operation through one of the following methods:</p><ul>
<li>A failed call to <a class="el" href="group__MAC.html#ga5560af371497babefe03c9da4e8a1c05">psa_mac_update()</a>.</li>
<li>A call to <a class="el" href="group__MAC.html#gac22bc0125580c96724a09226cfbc97f2">psa_mac_sign_finish()</a> or <a class="el" href="group__MAC.html#gacd8dd54855ba1bc0a03f104f252884fd">psa_mac_abort()</a>.</li>
</ul>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">operation</td><td>The operation object to use. </td></tr>
    <tr><td class="paramdir"></td><td class="paramname">key</td><td>Slot containing the key to use for the operation. </td></tr>
    <tr><td class="paramdir"></td><td class="paramname">alg</td><td>The MAC algorithm to compute (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#gaca7aee4c9dde316b3b1a150a26eab776">PSA_ALG_IS_MAC(alg)</a> is true).</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#gaba00e3e6ceb2b12965a81e5ac02ae040">PSA_ERROR_EMPTY_SLOT</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga4d1b8dd8526177a15a210b7afc1accb1">PSA_ERROR_NOT_PERMITTED</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td><code>key</code> is not compatible with <code>alg</code>. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td><code>alg</code> is not supported or is not a MAC algorithm. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga5560af371497babefe03c9da4e8a1c05"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5560af371497babefe03c9da4e8a1c05">&#9670;&nbsp;</a></span>psa_mac_update()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_mac_update </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *&#160;</td>
          <td class="paramname"><em>operation</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>input</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>input_length</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Add a message fragment to a multipart MAC operation.</p>
<p>The application must call <a class="el" href="group__MAC.html#ga68ac2ad3253e9e27fcfbc788a4df8177">psa_mac_sign_setup()</a> or <a class="el" href="group__MAC.html#gac7d1c3d075ce1604a54cbbc9933fa39d">psa_mac_verify_setup()</a> before calling this function.</p>
<p>If this function returns an error status, the operation becomes inactive.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active MAC operation. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">input</td><td>Buffer containing the message fragment to add to the MAC calculation. </td></tr>
    <tr><td class="paramdir"></td><td class="paramname">input_length</td><td>Size of the <code>input</code> buffer in bytes.</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not started, or already completed). </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gac92b2930d6728e1be4d011c05d485822"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac92b2930d6728e1be4d011c05d485822">&#9670;&nbsp;</a></span>psa_mac_verify_finish()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_mac_verify_finish </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *&#160;</td>
          <td class="paramname"><em>operation</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>mac</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>mac_length</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Finish the calculation of the MAC of a message and compare it with an expected value.</p>
<p>The application must call <a class="el" href="group__MAC.html#gac7d1c3d075ce1604a54cbbc9933fa39d">psa_mac_verify_setup()</a> before calling this function. This function calculates the MAC of the message formed by concatenating the inputs passed to preceding calls to <a class="el" href="group__MAC.html#ga5560af371497babefe03c9da4e8a1c05">psa_mac_update()</a>. It then compares the calculated MAC with the expected MAC passed as a parameter to this function.</p>
<p>When this function returns, the operation becomes inactive.</p>
<dl class="section note"><dt>Note</dt><dd>Implementations shall make the best effort to ensure that the comparison between the actual MAC and the expected MAC is performed in constant time.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">operation</td><td>Active MAC operation. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">mac</td><td>Buffer containing the expected MAC value. </td></tr>
    <tr><td class="paramdir"></td><td class="paramname">mac_length</td><td>Size of the <code>mac</code> buffer in bytes.</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>The expected MAC is identical to the actual MAC of the message. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga35927f755d232c4766de600f2c49e9f2">PSA_ERROR_INVALID_SIGNATURE</a></td><td>The MAC of the message was calculated successfully, but it differs from the expected MAC. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga933d40fa2a591004f2e93aa91e11db84">PSA_ERROR_BAD_STATE</a></td><td>The operation state is not valid (not started, or already completed). </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gac7d1c3d075ce1604a54cbbc9933fa39d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac7d1c3d075ce1604a54cbbc9933fa39d">&#9670;&nbsp;</a></span>psa_mac_verify_setup()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__basic.html#ga05676e70ba5c6a7565aff3c36677c1f9">psa_status_t</a> psa_mac_verify_setup </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__MAC.html#ga78f0838b0c4e3db28b26355624d4bd37">psa_mac_operation_t</a> *&#160;</td>
          <td class="paramname"><em>operation</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__platform.html#gac3da92a6b8a7f0c01dc348f8e0432e4c">psa_key_slot_t</a>&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__crypto__types.html#gac2e4d47f1300d73c2f829a6d99252d69">psa_algorithm_t</a>&#160;</td>
          <td class="paramname"><em>alg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Start a multipart MAC verification operation.</p>
<p>This function sets up the verification of the MAC (message authentication code) of a byte string against an expected value.</p>
<p>The sequence of operations to verify a MAC is as follows:</p><ol type="1">
<li>Allocate an operation object which will be passed to all the functions listed here.</li>
<li>Call <a class="el" href="group__MAC.html#gac7d1c3d075ce1604a54cbbc9933fa39d">psa_mac_verify_setup()</a> to specify the algorithm and key. The key remains associated with the operation even if the content of the key slot changes.</li>
<li>Call <a class="el" href="group__MAC.html#ga5560af371497babefe03c9da4e8a1c05">psa_mac_update()</a> zero, one or more times, passing a fragment of the message each time. The MAC that is calculated is the MAC of the concatenation of these messages in order.</li>
<li>At the end of the message, call <a class="el" href="group__MAC.html#gac92b2930d6728e1be4d011c05d485822">psa_mac_verify_finish()</a> to finish calculating the actual MAC of the message and verify it against the expected value.</li>
</ol>
<p>The application may call <a class="el" href="group__MAC.html#gacd8dd54855ba1bc0a03f104f252884fd">psa_mac_abort()</a> at any time after the operation has been initialized with <a class="el" href="group__MAC.html#gac7d1c3d075ce1604a54cbbc9933fa39d">psa_mac_verify_setup()</a>.</p>
<p>After a successful call to <a class="el" href="group__MAC.html#gac7d1c3d075ce1604a54cbbc9933fa39d">psa_mac_verify_setup()</a>, the application must eventually terminate the operation through one of the following methods:</p><ul>
<li>A failed call to <a class="el" href="group__MAC.html#ga5560af371497babefe03c9da4e8a1c05">psa_mac_update()</a>.</li>
<li>A call to <a class="el" href="group__MAC.html#gac92b2930d6728e1be4d011c05d485822">psa_mac_verify_finish()</a> or <a class="el" href="group__MAC.html#gacd8dd54855ba1bc0a03f104f252884fd">psa_mac_abort()</a>.</li>
</ul>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">operation</td><td>The operation object to use. </td></tr>
    <tr><td class="paramdir"></td><td class="paramname">key</td><td>Slot containing the key to use for the operation. </td></tr>
    <tr><td class="paramdir"></td><td class="paramname">alg</td><td>The MAC algorithm to compute (<code>PSA_ALG_XXX</code> value such that <a class="el" href="group__crypto__types.html#gaca7aee4c9dde316b3b1a150a26eab776">PSA_ALG_IS_MAC</a>(<code>alg</code>) is true).</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga4cc859e2c66ca381c7418db3527a65e1">PSA_SUCCESS</a></td><td>Success. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#gaba00e3e6ceb2b12965a81e5ac02ae040">PSA_ERROR_EMPTY_SLOT</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga4d1b8dd8526177a15a210b7afc1accb1">PSA_ERROR_NOT_PERMITTED</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga798df25a505ebf931f7bec1f80f1f85f">PSA_ERROR_INVALID_ARGUMENT</a></td><td><code>key</code> is not compatible with <code>alg</code>. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga1dcc6d130633ed5db8942257581b55dd">PSA_ERROR_NOT_SUPPORTED</a></td><td><code>alg</code> is not supported or is not a MAC algorithm. </td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga91b2ad8a867517a2651f1b076c5216e5">PSA_ERROR_INSUFFICIENT_MEMORY</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga5cdb6948371d49e916106249020ea3f7">PSA_ERROR_COMMUNICATION_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga08b10e70fa5ff0b05c631d9f8f6b2c6b">PSA_ERROR_HARDWARE_FAILURE</a></td><td></td></tr>
    <tr><td class="paramname"><a class="el" href="group__basic.html#ga2c5dda1485cb54f2385cb9c1279a7004">PSA_ERROR_TAMPERING_DETECTED</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
